package com.medical.manage.controller;

import com.medical.common.core.domain.Result;
import com.medical.common.core.web.controller.BaseController;
import com.medical.common.log.annotation.Log;
import com.medical.common.log.enums.BusinessType;
import com.medical.common.security.annotation.RequiresPermissions;
import com.medical.manage.domain.Department;
import com.medical.manage.domain.Diseases;
import com.medical.manage.mapper.DepartmentMapper;
import com.medical.manage.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

/**
 * @Author：waikaipeng
 * @Package：com.medical.manage.controller
 * @Project：medical
 * @name：DepartmentController
 * @Date：2025年3月7日 00:01
 */
@RestController
@RequestMapping("/department")
public class DepartmentController extends BaseController {
     @Autowired
     private DepartmentService departmentService;




     //科室查询
     @RequiresPermissions("manage:department:list")
    @GetMapping("/list")
    public Result list(Department department){
         startPage();
        List<Department> list = departmentService.list();
        return getDataTable(list);
    }


    //科室添加
    @RequiresPermissions("manage:department:add")
    @Log(title = "科室详情", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody Department department){
         departmentService.save(department);
        return success();
    }


    //科室修改
    @RequiresPermissions("manage:department:edit")
    @Log(title = "科室详情", businessType = BusinessType.INSERT)
    @PutMapping
    public Result edit(@RequestBody Department department){
       departmentService.updateById(department);
       return success();
    }


    //科室删除
    @RequiresPermissions("manage:department:remove")
    @Log(title = "科室详情", businessType = BusinessType.INSERT)
    @DeleteMapping("/{departmentIds}")
    public Result remove(@PathVariable Long[] departmentIds){
        List<Long> list = Arrays.asList(departmentIds);
        departmentService.removeBatchByIds(list);
        return success();

    }
}
